import { request } from '../utils/http/request.js';
/**
 * 登录接口
 * @param {username,password} data
 * @returns
 */
export function login(data) {
    return new Promise((resolve, reject) => {
        request({
            method: 'post',
            url: '/system/systemapi/menhulogin',
            params: data
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}
/**
 * 专家列表
 */
export function expertlist(data) {
    return new Promise((resolve, reject) => {
        request({
            method: 'get',
            url: '/sinopeclab/labcommonapi/expertlist',
            params: data
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

/**
 * 科研动态列表
 */
export function findinglist(data) {
    return new Promise((resolve, reject) => {
        request({
            method: 'get',
            url: '/sinopeclab/labcommonapi/findinglist',
            params: data
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

/**
 * 获取首页banner
 */
export function banners(data) {
    return new Promise((resolve, reject) => {
        request({
            method: 'get',
            url: '/sinopeclab/labcommonapi/banners',
            params: data
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

/**
 * 获取系统新闻列表
 */
export function noticelist(data) {
    return new Promise((resolve, reject) => {
        request({
            method: 'get',
            url: '/system/systemapi/noticelist',
            params: data
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}
/**
 * 获取新闻通知详情
 */
export function noticeinfo(data) {
    return new Promise((resolve, reject) => {
        request({
            method: 'get',
            url: '/system/systemapi/noticeinfo',
            params: data
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}
/**
 * 科研动态详细信息
 */
export function findinginfo(data) {
    return new Promise((resolve, reject) => {
        request({
            method: 'get',
            url: '/sinopeclab/labcommonapi/findinginfo',
            params: data
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

/**
 * 获取设备列表
 */
export function equipmentList(data) {
    return new Promise((resolve, reject) => {
        request({
            method: 'get',
            url: '/device/labdeviceapi/list',
            params: data
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

/**
 * 获取设备详情
 */
export function getequipmentinfo(data) {
    return new Promise((resolve, reject) => {
        request({
            method: 'get',
            url: '/device/labdeviceapi/getInfo',
            params: data
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

/**
 * 获取用户预约列表
 */
export function orderlist(data) {
    return new Promise((resolve, reject) => {
        request({
            method: 'get',
            url: '/device/labdeviceapi/orderlist',
            params: data,
            type: 1
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}


export function devicelist(data) {
    console.log(data)
    return new Promise((resolve, reject) => {
        request({
            method: 'get',
            url: '/device/labdeviceapi/list',
            params: data,
            // type: 1

        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

export function yuyue(data) {
    return new Promise((resolve, reject) => {
        request({
            method: 'post',
            url: '/device/labdeviceapi/yuyue',
            params: data,
            type: 1
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

export function deviceorderlist(data) {
    return new Promise((resolve, reject) => {
        request({
            method: 'get',
            url: '/sinopeclab/deviceorder/deviceorderlist',
            params: data,
            type: 1
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}


/**
 * 用户注册
 */
export function register(data) {
    return new Promise((resolve, reject) => {
        request({
            method: 'post',
            url: '/sinopeclab/labcommonapi/register',
            params: data
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

// 获取实验室
export function getLabList(data) {
    return new Promise((resolve, reject) => {
        request({
            method: 'get',
            url: '/sinopeclab/labcommonapi/lablist',
            params: data,
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

// 查询部门下拉树结构
export function treeselect() {
    return new Promise((resolve, reject) => {
        request({
            method: 'get',
            url: '/system/systemapi/treeselect',
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

/**
 * 获取字典数据
 * @param data
 * @returns {Promise<unknown>}
 */
export function getSysDictData(data) {
    return new Promise((resolve, reject) => {
        request({
            method: 'get',
            url: '/system/systemapi/noticeinfo',
            params: data
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

export function sysDictData(data) {
    return new Promise((resolve, reject) => {
        request({
            method: 'get',
            url: '/system/systemapi/sysDictData',
            params: data
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

// 回显数据字典
export function selectDictLabel(datas, value) {
    var actions = [];
    Object.keys(datas).some((key) => {
        if (datas[key].dictValue == ('' + value)) {
            actions.push(datas[key].dictLabel);
            return true;
        }
    })
    return actions.join('');
}

/**
 * 获取
 */
